const http = uni.$u.http
import { baseUrl } from "../common/http.interceptor";

export default {
    /**
     * 用户
     */
    uploadImage: baseUrl + '/upload/file',
    getUserInfo: (id) => http.get('/user/' + id),
    updateUser: (id, data) => http.put('/user/' + id, data),
    wxLogin: (data) => http.post('/user/wx/login', data),
    getBannerList: (params) => http.get('/banner/list', params),
    getProductCategoryList: (params) => http.get('/productCategory/list', params),
    getProductList: (params) => http.get('/product', params),
    getProductDetail: (id) => http.get(`/product/${id}`),
    addCart: (data) => http.post(`/cart`, data),
    getCartList: (data) => http.get(`/cart`, data),
    deleteCart: (data) => http.post(`/cart/batchDelete`, data),
    updateCart: (data) => http.put(`/cart/` + data.id, data),
    updateCartStatusAll: (data) => http.post(`/cart/statusAll`, data),
    updateAddress: (data) => http.put(`/address/` + data.id, data),
    getAddressList: (data) => http.get(`/address`, data),
    getLogisticsList: (data) => http.get(`/logistics`, data),
    addAddress: (data) => http.post(`/address`, data),
    getAddressDetail: (id) => http.get(`/address/${id}`),
    deleteAddress: (id) => http.delete(`/address/${id}`),
    // 章节
    getChapterList: (params) => http.get('/productItem', params),
    // 章节详情
    getChapterDetail: (id) => http.get(`/productItem/${id}`),
    // 获取评论
    getCommentList: (data) => http.get(`/comment`, data),
    // 发表评论
    addComment: (data) => http.post(`/comment`, data),
    // 我的收藏商品
    getCollect: (data) => http.get(`/collection/product`, data),
    getCollectionList: (data) => http.get(`/collection`, data),
    updateCollect: (data) => http.post(`/collection`, data),
    // 订单
    createOrder: (data) => http.post(`/order`, data),
    getOrderPage: (data) => http.get(`/order`, data),
    getOrderList: (data) => http.get(`/order/list`, data),
    getOrderDetail: (id) => http.get(`/order/${id}`),
    createPay: (data) => http.post(`/payment/wx`, data),
    cancelOrder: (data) => http.post(`/order/cancel`, data),
    refundOrder: (data) => http.post(`/order/refund`, data),
    confirmRefund: (data) => http.post(`/order/refund/confirm`, data),
    // 检测产品是否已购买
    checkProduct: (data) => http.get(`/userProduct/check`, data),
    getHistoryList: (data) => http.get(`/userProduct`, data),
    addFeedback: (data) => http.post(`/feedback`, data),
    exchangeCode: (data) => http.post(`/cdk/exchange`, data),
    search: (data) => http.get(`/search`, data),
}
